package com.crux.jpa.version.controller;

import com.crux.jpa.version.entity.User;
import com.crux.jpa.version.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/user")
public class UserController {
    private UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("/add")
    public User addUser(@RequestParam String name) {
        return userService.addUser(name);
    }

    @GetMapping("/modify")
    public void modify() {
        userService.modify();
    }


    @GetMapping("/batch")
    public int batch(){
        return userService.batchInsert();
    }

    @GetMapping("/test")
    public int test(){
        return userService.test();
    }


    @GetMapping("/test2")
    public int test2(){
        return userService.test2();
    }
}
